package com.help.controller;

import com.common.domain.pojo.Result;
import com.help.domain.pojo.HelpCategory;
import com.help.domain.vo.HelpCenterVo;
import com.help.service.IHelpItemService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 二级分类与内容表 前端控制器
 * </p>
 *
 * @author 小杰大人
 * @since 2025-10-08
 */
@RestController
@RequestMapping("/api/help")
public class HelpItemController {
    @Resource
    IHelpItemService iHelpItemService;

    // 获取帮助中心一级标题
    @GetMapping("/categorys")
    public Result<List<HelpCategory>> getHelpCategorys() {
        List<HelpCategory> categories = iHelpItemService.getHelpCategorys();
        return Result.success(categories);
    }

    // 根据一级标题Id获取二级标题以及内容
    @GetMapping("/helpCenter/{categoryId}")
    public Result<List<HelpCenterVo>> getHelpCenter(@PathVariable("categoryId") Integer categoryId) {
        List<HelpCenterVo> helpCenter = iHelpItemService.getHelpCenter(categoryId);
        return Result.success(helpCenter);
    }
}
